<%--
  User: ganesh
  Date: May 30, 2007
  Time: 2:52:55 PM
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ page import="com.scalar.chiptrack.commons.Constants,
                 com.scalar.chiptrack.utils.ConfigManager"%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<chiptrack:checkLogon sourcePage="/reelQtyAction.do" />
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HTML>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet"></HEAD>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>

<SCRIPT language="JavaScript">
    var listSize=0;

    function addTextArea()
    {

        var tab = document.getElementById ("reelQtyTable");
        var index = document.getElementById ("rowIndex").rowIndex;
        var newRow = tab.insertRow ( index );
        newRow.bgColor = ( listSize % 2 == 0 ) ? '#FFFFEE' : '#DEE1E2';
        var newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.align="center";
        var htmltext = '<select name="reelQtyList['+ listSize+'].packageName" class="txfield" ><option value="-1" >Select Package </option>';
        <logic:iterate id="packageName" name="packagesList" type="org.apache.struts.util.LabelValueBean">
        <%
            out.println( "htmltext += '<option value=\"" + packageName.getValue() + "\">" + packageName.getLabel() + "</option>'" );
        %>
        </logic:iterate>
        htmltext += '</select>';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.align="center";
        htmltext = '<select name="reelQtyList['+ listSize+'].pinCount" class="txfield" ><option value="-1" >Select Pin Count</option>';
        <logic:iterate id="pin" name="pinsList" type="org.apache.struts.util.LabelValueBean">
        <%
            out.println( "htmltext += '<option value=\"" + pin.getValue() + "\">" + pin.getLabel() + "</option>'" );
        %>
        </logic:iterate>
        htmltext += '</select>';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.align="center";
        htmltext = '<input type="text" name="reelQtyList['+ listSize+'].reelQty" class="valueTxfield" size="5" onkeypress="javascript:numericFieldKeyPress( this )">';
        newCell.innerHTML = htmltext;

        listSize++;
    }


    function reset()
    {
        document.reelqtyForm.reset();
        var form = document.reelqtyForm;
        for ( var i=0; i< listSize; i++)
        {
            enableDisableReelQuantitys(i);
        }
    }
    function enableDisableReelQuantitys(idx)
    {
        var form = document.reelqtyForm;
        var exist = form['reelQtyList['+ idx +'].exist'];
        if( exist )
        {
            form['reelQtyList['+ idx +'].packageName'].disabled = true;
            form['reelQtyList['+ idx +'].pinCount'].disabled = true;
        }
        else
        {
            form['reelQtyList['+ idx +'].packageName'].disabled = false;
            form['reelQtyList['+ idx +'].pinCount'].disabled = false;
        }
    }
    function submitPage()
    {
        var form    = document.reelqtyForm;
        form.action = "<%=chipTracContext%>/reelQtyAction.do?action=loadReelQtys"
        form.submit();
    }
    function save()
    {
        var form    = document.reelqtyForm;
        enableFields();
        form.action = "<%=chipTracContext%>/reelQtyAction.do?action=saveReelQtys"
        form.submit();
    }

    function enableFields()
    {
        var form    = document.reelqtyForm;
        for ( var i=0; i < listSize; i++ )
        {
            form['reelQtyList['+ i +'].packageName'].disabled = false;
            form['reelQtyList['+ i +'].pinCount'].disabled = false;            
        }
    }

</SCRIPT>
<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">
<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
    <TR>
	    <TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
	    <!-- Side Navigation start -->
	    <%@include file="/jsp/operations/releaseMenu.jsp" %>
	    <!-- end of the side navigations -->
        </TD>
	    <TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
	    <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
	    <TD valign="top" width="100%"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
	    <BR>
        <html:form action="/reelQtyAction.do" name="reelqtyForm" type="com.scalar.chiptrack.operations.tapereel.forms.ReelQtyForm">
            <input type="hidden" name="isSearchSubmit" value="true">
            <TABLE width="80%" align="center" cellpadding="2" cellspacing="2" border="0">
			    <TR><TD colspan="5" class="NArialW" align="center">Reel Quantity Setup</TD></TR>
			    <TR><TD colspan='5' class="NArialL"><chiptrack:errors styleClass="NArialL"/><chiptrack:info styleClass="NArialL"/></TD></TR>
			    <TR><TD colspan='5' class="NArialL"><FONT id="errors" color='FF0000'></font></TD></TR>

                <tr>
                    <td class="NArialL"> Package: </td>
                    <td class="NArialL">
                        <nested:select name="reelqtyForm" property="packageName"  styleClass="txfield" >
                            <html:option value="0" >All Packages</html:option>
                            <logic:present name="packagesList">
                                <html:options collection="packagesList" property="value" labelProperty="label"/>
                            </logic:present>
                        </nested:select>
                    </td>
                    <td width="5%">&nbsp;</td>
                    <td class="NArialL" width="10%">
                      Pin Count:
                    </td>
                    <td class="NArialL" align="left">
                        <nested:select name="reelqtyForm" property="pinCount"  styleClass="txfield" >
                        <html:option value="0">All Pins</html:option>
                        <logic:present name="pinsList">
                            <html:options collection="pinsList" property="value" labelProperty="label"/>
                        </logic:present>
                    </nested:select>
                    </td>
            </tr>
            <TR><TD colspan='5'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
			<tr>
				<td colspan="5" align="center">
                    <a href="javascript:submitPage()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" onmouseover="window.status='Click to Search Product Reel Quantity ';return true" onmouseout="window.status='';return true" title="Click here to Search Product Reel Quantity" alt=""></a>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				    <a href="javascript:reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
				</td>
			</tr>

            <TR><TD colspan='5'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>

            <tr>
                <td colspan="5" >
                    <table width="100%" id="reelQtyTable">
                        <tr bgcolor="#993333">
                            <td align="center" class="NArialL"><font color="#FFFFFF">Package </font></td>
                            <td align="center" class="NArialL"><font color="#FFFFFF">Pin Count</font></td>
                            <td align="center" class="NArialL"><font color="#FFFFFF">Reel Qty</font></td>
                        </tr>
                    <nested:present property="reelQtyList">
                        <nested:size id="listSize" property="reelQtyList"/>
                            <script type="text/javascript">
                                listSize=<%=listSize.intValue() %>;
                            </script>
                            <logic:greaterThan value="0" name="listSize" >
                            <nested:iterate id="reelQtyId" property="reelQtyList" indexId="iterateIdx" type="com.scalar.chiptrack.operations.tapereel.ReelQty">
                                <%
                                    boolean isDisabled = reelQtyId.isExist();
                                %>
                            <nested:hidden property="exist"/>
                            <tr bgcolor=<%=iterateIdx.intValue() % 2 == 0 ? "'#FFFFEE'" : "'#DEE1E2'"%> >
                                <td align="center" class="NArialL" >
                                <nested:select property="packageName"  styleClass="txfield" disabled="<%=isDisabled%>" >
                                    <logic:present name="packagesList">
                                        <html:option value="-1">Select Package</html:option>
                                        <html:options collection="packagesList" property="value" labelProperty="label"/>
                                    </logic:present>
                                </nested:select>
                                </td>
                                <td align="center" class="NArialL" >
                                    <nested:select property="pinCount"  styleClass="txfield"  disabled="<%=isDisabled%>">
                                        <logic:present name="pinsList">
                                        <html:option value="-1">Select Pin Count</html:option>
                                        <html:options collection="pinsList" property="value" labelProperty="label"/>
                                    </logic:present>
                                </nested:select>
                            </td>
                            <td align="center" class="NArialL" ><nested:text property="reelQty" styleClass="valueTxfield" size="5" onkeypress="javascript:numericFieldKeyPress( this )"/></td>
                        </tr>                        
                        </nested:iterate>
                        </logic:greaterThan>
                        </nested:present>
                        <tr id="rowIndex"></tr>
                        <tr>
                            <td colspan="3" align="right"><a href="javascript:addTextArea();"><img src="<%=chipTracContext%>/jsp/includes/images/addmore.gif" border=0 onmouseover="window.status='Click here to Add new Reel Qty';return true" onmouseout="window.status='';return true" title="Click here to Add new Reel Qty"></a></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <TR><TD colspan='5'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
            <tr>
                <td colspan="5" align="center">
                    <a href="javascript:save()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" onmouseover="window.status='Click to Search Product Reel Quantity';return true" onmouseout="window.status='';return true" title="Click here to save Reel Quantity Setup " alt=""></a>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="javascript:reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
                </td>
            </tr>


        </TABLE>
	</html:form>
<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</HTML>
